{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "ROI_ecg_fractal_analysis implements functions for determining ECG ROI in order to optimize computational complexity when applying features."
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Importing requiered packages"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import h5py\n",
    "import neurokit2 as nk"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Get ECG signal lead X for analysis. Next methodology is keeped only for knowledge purposes. Actually its no in used."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [],
   "source": [
    "with h5py.File('E:/1-DENIS/Biomarkers/SPH dataset/records/A00001.h5', 'r') as f:\n",
    "    test_signal = f['ecg'][2]"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Apply Neurokit ecg_process. In processed variable a dataframe with ECG fiducial points for P-QRS-T waves"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [],
   "source": [
    "processed, _ = nk.ecg_process(test_signal, sampling_rate=500)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Get ECG fiducial points for P-QRS-T waves. From ECG_P_Onsets to ECG_T_Offsets. Additionally ECG_R_Peaks fiducial points are also marked"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [],
   "source": [
    "fid_start = list(processed[processed['ECG_P_Onsets'] == 1].index)\n",
    "fid_end = list(processed[processed['ECG_T_Offsets'] == 1].index)\n",
    "fid_r = list(processed[processed['ECG_R_Peaks'] == 1].index)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "def create_segments(fiducial_start, fiducial_end), returns initial and final fiducial points implied in ECG ROI (P-QRS-T). This function must be reviewed because P and T waves are not always detected (because its amplitude and the used ECG lead) and differences in P and T segments appear, so pairing initial and final points needs validation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {},
   "outputs": [],
   "source": [
    "def create_segments(fiducial_start, fiducial_end):\n",
    "    segments = []\n",
    "    if len(fiducial_start) > len(fiducial_end):\n",
    "        index = range(len(fid_start))\n",
    "        for index, first, second in zip(index, fiducial_start, fiducial_end):\n",
    "            if (second - first) > 0 and (second - first) <= 400:\n",
    "                segments.append([first, second])\n",
    "            else:\n",
    "                fid_end.insert(index, np.NaN)\n",
    "    elif len(fid_end) > len(fid_start):\n",
    "         index = range(len(fid_end))\n",
    "         for index, first, second in zip(index, fiducial_start, fiducial_end):\n",
    "            if (second - first) > 0 and (second - first) <= 400:\n",
    "                segments.append([first, second])\n",
    "            else:\n",
    "                fid_start.insert(index, np.NaN)\n",
    "    else:\n",
    "        index = range(len(fid_start))\n",
    "        for index, first, second in zip(index, fiducial_start, fiducial_end):\n",
    "            if (second - first) > 0 and (second - first) <= 400:\n",
    "                segments.append([first, second])\n",
    "            elif (second - first) < 0 and (second - first) <= 400:\n",
    "                fid_start.insert(index, np.NaN)\n",
    "            elif (second - first) > 0 and (second - first) > 400:\n",
    "                fid_end.insert(index, np.NaN)\n",
    "\n",
    "    return segments"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [],
   "source": [
    "s = create_segments(fid_start, fid_end)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[697, 912], [1941, 2165], [2499, 2673], [3138, 3334], [3731, 4050]]"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "398  -  nan  =  nan\n",
      "912  -  697  =  215\n",
      "nan  -  1267  =  nan\n",
      "2165  -  1941  =  224\n",
      "2673  -  2499  =  174\n",
      "3334  -  3138  =  196\n",
      "4050  -  3731  =  319\n",
      "4525  -  4346  =  179\n"
     ]
    }
   ],
   "source": [
    "for first, second in zip(fid_start, fid_end):\n",
    "    print(second, ' - ' ,first, ' = ' ,second - first)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Definitory method: indeed of using P and T fiducial points in order to obtain the ECG ROI, it is simpler to use an interval window of -150 and +150 around the ECG_R_Peaks, in order to simplify computations "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "Katz_list = [np.NaN] * 15\n",
    "with h5py.File('E:/1-DENIS/Biomarkers/SPH dataset/records/A00002.h5', 'r') as f:\n",
    "    Katz_derivations_dataframe = pd.DataFrame(columns = [c for c in range(15)])\n",
    "    for der in range (12):\n",
    "        ecg_sig = f['ecg'][der]\n",
    "        signals, _ = nk.ecg_process(ecg_sig, sampling_rate=500)\n",
    "        roi_ref = list(signals[signals['ECG_R_Peaks'] == 1].index)\n",
    "                    \n",
    "        for i in range(len(roi_ref)):\n",
    "            temp, _ = nk.fractal_katz(ecg_sig[roi_ref[i] - 150: roi_ref[i] + 150])\n",
    "            Katz_list[i] = temp\n",
    "                    \n",
    "        Katz_derivations_dataframe.loc[len(Katz_derivations_dataframe)] = Katz_list\n",
    "        Katz_list = [np.NaN] * 15\n",
    "\n",
    "Katz_derivations_dataframe.index = [['I', 'II', 'III', 'aVR', 'aVL', 'aVF', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6']]\n",
    "Katz_derivations_dataframe.dropna(axis=1, inplace=True)    "
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Katz_derivations_dataframe in the form leads vs Katz values for obtained ROI's"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>10</th>\n",
       "      <th>11</th>\n",
       "      <th>12</th>\n",
       "      <th>13</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>1.245117</td>\n",
       "      <td>1.245117</td>\n",
       "      <td>1.250977</td>\n",
       "      <td>1.249023</td>\n",
       "      <td>1.264648</td>\n",
       "      <td>1.244141</td>\n",
       "      <td>1.237305</td>\n",
       "      <td>1.245117</td>\n",
       "      <td>1.256836</td>\n",
       "      <td>1.241211</td>\n",
       "      <td>1.241211</td>\n",
       "      <td>1.249023</td>\n",
       "      <td>1.245117</td>\n",
       "      <td>1.242188</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>II</th>\n",
       "      <td>1.205078</td>\n",
       "      <td>1.190430</td>\n",
       "      <td>1.195312</td>\n",
       "      <td>1.201172</td>\n",
       "      <td>1.196289</td>\n",
       "      <td>1.194336</td>\n",
       "      <td>1.190430</td>\n",
       "      <td>1.194336</td>\n",
       "      <td>1.192383</td>\n",
       "      <td>1.191406</td>\n",
       "      <td>1.196289</td>\n",
       "      <td>1.190430</td>\n",
       "      <td>1.194336</td>\n",
       "      <td>1.191406</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>III</th>\n",
       "      <td>1.280273</td>\n",
       "      <td>1.227539</td>\n",
       "      <td>1.244141</td>\n",
       "      <td>1.263672</td>\n",
       "      <td>1.232422</td>\n",
       "      <td>1.253906</td>\n",
       "      <td>1.251953</td>\n",
       "      <td>1.254883</td>\n",
       "      <td>1.239258</td>\n",
       "      <td>1.246094</td>\n",
       "      <td>1.250977</td>\n",
       "      <td>1.238281</td>\n",
       "      <td>1.238281</td>\n",
       "      <td>1.257812</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVR</th>\n",
       "      <td>1.214844</td>\n",
       "      <td>1.208008</td>\n",
       "      <td>1.211914</td>\n",
       "      <td>1.214844</td>\n",
       "      <td>1.215820</td>\n",
       "      <td>1.208984</td>\n",
       "      <td>1.208008</td>\n",
       "      <td>1.209961</td>\n",
       "      <td>1.205078</td>\n",
       "      <td>1.203125</td>\n",
       "      <td>1.208008</td>\n",
       "      <td>1.208984</td>\n",
       "      <td>1.208008</td>\n",
       "      <td>1.214844</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVL</th>\n",
       "      <td>1.356445</td>\n",
       "      <td>1.359375</td>\n",
       "      <td>1.365234</td>\n",
       "      <td>1.353516</td>\n",
       "      <td>1.446289</td>\n",
       "      <td>1.353516</td>\n",
       "      <td>1.333008</td>\n",
       "      <td>1.344727</td>\n",
       "      <td>1.414062</td>\n",
       "      <td>1.377930</td>\n",
       "      <td>1.337891</td>\n",
       "      <td>1.369141</td>\n",
       "      <td>1.387695</td>\n",
       "      <td>1.338867</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVF</th>\n",
       "      <td>1.209961</td>\n",
       "      <td>1.183594</td>\n",
       "      <td>1.189453</td>\n",
       "      <td>1.201172</td>\n",
       "      <td>1.187500</td>\n",
       "      <td>1.190430</td>\n",
       "      <td>1.191406</td>\n",
       "      <td>1.192383</td>\n",
       "      <td>1.190430</td>\n",
       "      <td>1.188477</td>\n",
       "      <td>1.198242</td>\n",
       "      <td>1.190430</td>\n",
       "      <td>1.190430</td>\n",
       "      <td>1.190430</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V1</th>\n",
       "      <td>1.208984</td>\n",
       "      <td>1.186523</td>\n",
       "      <td>1.186523</td>\n",
       "      <td>1.187500</td>\n",
       "      <td>1.184570</td>\n",
       "      <td>1.190430</td>\n",
       "      <td>1.187500</td>\n",
       "      <td>1.192383</td>\n",
       "      <td>1.192383</td>\n",
       "      <td>1.187500</td>\n",
       "      <td>1.195312</td>\n",
       "      <td>1.190430</td>\n",
       "      <td>1.189453</td>\n",
       "      <td>1.189453</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V2</th>\n",
       "      <td>1.244141</td>\n",
       "      <td>1.240234</td>\n",
       "      <td>1.236328</td>\n",
       "      <td>1.237305</td>\n",
       "      <td>1.244141</td>\n",
       "      <td>1.231445</td>\n",
       "      <td>1.234375</td>\n",
       "      <td>1.238281</td>\n",
       "      <td>1.236328</td>\n",
       "      <td>1.236328</td>\n",
       "      <td>1.232422</td>\n",
       "      <td>1.236328</td>\n",
       "      <td>1.237305</td>\n",
       "      <td>1.235352</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V3</th>\n",
       "      <td>1.355469</td>\n",
       "      <td>1.355469</td>\n",
       "      <td>1.378906</td>\n",
       "      <td>1.378906</td>\n",
       "      <td>1.343750</td>\n",
       "      <td>1.340820</td>\n",
       "      <td>1.367188</td>\n",
       "      <td>1.345703</td>\n",
       "      <td>1.330078</td>\n",
       "      <td>1.361328</td>\n",
       "      <td>1.405273</td>\n",
       "      <td>1.376953</td>\n",
       "      <td>1.409180</td>\n",
       "      <td>1.398438</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V4</th>\n",
       "      <td>1.251953</td>\n",
       "      <td>1.244141</td>\n",
       "      <td>1.267578</td>\n",
       "      <td>1.267578</td>\n",
       "      <td>1.264648</td>\n",
       "      <td>1.252930</td>\n",
       "      <td>1.255859</td>\n",
       "      <td>1.256836</td>\n",
       "      <td>1.253906</td>\n",
       "      <td>1.257812</td>\n",
       "      <td>1.250000</td>\n",
       "      <td>1.257812</td>\n",
       "      <td>1.256836</td>\n",
       "      <td>1.267578</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V5</th>\n",
       "      <td>1.214844</td>\n",
       "      <td>1.196289</td>\n",
       "      <td>1.190430</td>\n",
       "      <td>1.204102</td>\n",
       "      <td>1.216797</td>\n",
       "      <td>1.201172</td>\n",
       "      <td>1.209961</td>\n",
       "      <td>1.225586</td>\n",
       "      <td>1.213867</td>\n",
       "      <td>1.198242</td>\n",
       "      <td>1.204102</td>\n",
       "      <td>1.202148</td>\n",
       "      <td>1.203125</td>\n",
       "      <td>1.199219</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V6</th>\n",
       "      <td>1.163086</td>\n",
       "      <td>1.162109</td>\n",
       "      <td>1.173828</td>\n",
       "      <td>1.184570</td>\n",
       "      <td>1.172852</td>\n",
       "      <td>1.175781</td>\n",
       "      <td>1.184570</td>\n",
       "      <td>1.178711</td>\n",
       "      <td>1.159180</td>\n",
       "      <td>1.186523</td>\n",
       "      <td>1.195312</td>\n",
       "      <td>1.191406</td>\n",
       "      <td>1.170898</td>\n",
       "      <td>1.173828</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           0         1         2         3         4         5         6   \\\n",
       "I    1.245117  1.245117  1.250977  1.249023  1.264648  1.244141  1.237305   \n",
       "II   1.205078  1.190430  1.195312  1.201172  1.196289  1.194336  1.190430   \n",
       "III  1.280273  1.227539  1.244141  1.263672  1.232422  1.253906  1.251953   \n",
       "aVR  1.214844  1.208008  1.211914  1.214844  1.215820  1.208984  1.208008   \n",
       "aVL  1.356445  1.359375  1.365234  1.353516  1.446289  1.353516  1.333008   \n",
       "aVF  1.209961  1.183594  1.189453  1.201172  1.187500  1.190430  1.191406   \n",
       "V1   1.208984  1.186523  1.186523  1.187500  1.184570  1.190430  1.187500   \n",
       "V2   1.244141  1.240234  1.236328  1.237305  1.244141  1.231445  1.234375   \n",
       "V3   1.355469  1.355469  1.378906  1.378906  1.343750  1.340820  1.367188   \n",
       "V4   1.251953  1.244141  1.267578  1.267578  1.264648  1.252930  1.255859   \n",
       "V5   1.214844  1.196289  1.190430  1.204102  1.216797  1.201172  1.209961   \n",
       "V6   1.163086  1.162109  1.173828  1.184570  1.172852  1.175781  1.184570   \n",
       "\n",
       "           7         8         9         10        11        12        13  \n",
       "I    1.245117  1.256836  1.241211  1.241211  1.249023  1.245117  1.242188  \n",
       "II   1.194336  1.192383  1.191406  1.196289  1.190430  1.194336  1.191406  \n",
       "III  1.254883  1.239258  1.246094  1.250977  1.238281  1.238281  1.257812  \n",
       "aVR  1.209961  1.205078  1.203125  1.208008  1.208984  1.208008  1.214844  \n",
       "aVL  1.344727  1.414062  1.377930  1.337891  1.369141  1.387695  1.338867  \n",
       "aVF  1.192383  1.190430  1.188477  1.198242  1.190430  1.190430  1.190430  \n",
       "V1   1.192383  1.192383  1.187500  1.195312  1.190430  1.189453  1.189453  \n",
       "V2   1.238281  1.236328  1.236328  1.232422  1.236328  1.237305  1.235352  \n",
       "V3   1.345703  1.330078  1.361328  1.405273  1.376953  1.409180  1.398438  \n",
       "V4   1.256836  1.253906  1.257812  1.250000  1.257812  1.256836  1.267578  \n",
       "V5   1.225586  1.213867  1.198242  1.204102  1.202148  1.203125  1.199219  \n",
       "V6   1.178711  1.159180  1.186523  1.195312  1.191406  1.170898  1.173828  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "Katz_derivations_dataframe"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Determining best ECG lead based on standard deviation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "V4     0.005993\n",
       "V5     0.006021\n",
       "V6     0.007596\n",
       "V3     0.011656\n",
       "V2     0.015221\n",
       "V1     0.026165\n",
       "aVR    0.028192\n",
       "II     0.039433\n",
       "aVF    0.047513\n",
       "III    0.052645\n",
       "I      0.058803\n",
       "aVL    0.062628\n",
       "dtype: float64"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Katz_derivations_dataframe.std(axis=1).sort_values(ascending=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "I      0.055786\n",
       "II     0.037409\n",
       "III    0.049944\n",
       "aVR    0.026745\n",
       "aVL    0.059414\n",
       "aVF    0.045075\n",
       "V1     0.024823\n",
       "V2     0.014440\n",
       "V3     0.011058\n",
       "V4     0.005685\n",
       "V5     0.005712\n",
       "V6     0.007206\n",
       "dtype: float64"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.std(Katz_derivations_dataframe, axis=1)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Generalizing procedure for all normal ECG signals for Katz fractal dimensional feature"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ECG_ID</th>\n",
       "      <th>Age</th>\n",
       "      <th>Age_class_0</th>\n",
       "      <th>Age_class_1</th>\n",
       "      <th>Age_class_2</th>\n",
       "      <th>Age_class_3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A00002</td>\n",
       "      <td>32</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>A00003</td>\n",
       "      <td>63</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>A00006</td>\n",
       "      <td>46</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>A00008</td>\n",
       "      <td>32</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>A00009</td>\n",
       "      <td>48</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   ECG_ID  Age  Age_class_0  Age_class_1  Age_class_2  Age_class_3\n",
       "0  A00002   32            2            1            0            0\n",
       "1  A00003   63            5            2            1            1\n",
       "2  A00006   46            3            1            1            0\n",
       "3  A00008   32            2            1            0            0\n",
       "4  A00009   48            3            1            1            0"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "normal_ecg_age = pd.read_pickle('normal_ecg_age.pickle')\n",
    "normal_ecg_age.head()"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A00002\n",
      "A00003\n",
      "A00006\n",
      "A00008\n",
      "A00009\n",
      "A00010\n",
      "A00012\n",
      "A00014\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\fromnumeric.py:3464: RuntimeWarning: Mean of empty slice.\n",
      "  return _methods._mean(a, axis=axis, dtype=dtype,\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide\n",
      "  ret = ret.dtype.type(ret / rcount)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A00016\n",
      "A00017\n",
      "A00019\n",
      "A00021\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\fromnumeric.py:3464: RuntimeWarning: Mean of empty slice.\n",
      "  return _methods._mean(a, axis=axis, dtype=dtype,\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide\n",
      "  ret = ret.dtype.type(ret / rcount)\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\fromnumeric.py:3464: RuntimeWarning: Mean of empty slice.\n",
      "  return _methods._mean(a, axis=axis, dtype=dtype,\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide\n",
      "  ret = ret.dtype.type(ret / rcount)\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\fromnumeric.py:3464: RuntimeWarning: Mean of empty slice.\n",
      "  return _methods._mean(a, axis=axis, dtype=dtype,\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide\n",
      "  ret = ret.dtype.type(ret / rcount)\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\fromnumeric.py:3464: RuntimeWarning: Mean of empty slice.\n",
      "  return _methods._mean(a, axis=axis, dtype=dtype,\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide\n",
      "  ret = ret.dtype.type(ret / rcount)\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\fromnumeric.py:3464: RuntimeWarning: Mean of empty slice.\n",
      "  return _methods._mean(a, axis=axis, dtype=dtype,\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide\n",
      "  ret = ret.dtype.type(ret / rcount)\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\fromnumeric.py:3464: RuntimeWarning: Mean of empty slice.\n",
      "  return _methods._mean(a, axis=axis, dtype=dtype,\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide\n",
      "  ret = ret.dtype.type(ret / rcount)\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\fromnumeric.py:3464: RuntimeWarning: Mean of empty slice.\n",
      "  return _methods._mean(a, axis=axis, dtype=dtype,\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide\n",
      "  ret = ret.dtype.type(ret / rcount)\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\fromnumeric.py:3464: RuntimeWarning: Mean of empty slice.\n",
      "  return _methods._mean(a, axis=axis, dtype=dtype,\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide\n",
      "  ret = ret.dtype.type(ret / rcount)\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\fromnumeric.py:3464: RuntimeWarning: Mean of empty slice.\n",
      "  return _methods._mean(a, axis=axis, dtype=dtype,\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide\n",
      "  ret = ret.dtype.type(ret / rcount)\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\fromnumeric.py:3464: RuntimeWarning: Mean of empty slice.\n",
      "  return _methods._mean(a, axis=axis, dtype=dtype,\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide\n",
      "  ret = ret.dtype.type(ret / rcount)\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\fromnumeric.py:3464: RuntimeWarning: Mean of empty slice.\n",
      "  return _methods._mean(a, axis=axis, dtype=dtype,\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide\n",
      "  ret = ret.dtype.type(ret / rcount)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A00024\n",
      "A00025\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\fromnumeric.py:3464: RuntimeWarning: Mean of empty slice.\n",
      "  return _methods._mean(a, axis=axis, dtype=dtype,\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide\n",
      "  ret = ret.dtype.type(ret / rcount)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A00026\n",
      "A00027\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\fromnumeric.py:3464: RuntimeWarning: Mean of empty slice.\n",
      "  return _methods._mean(a, axis=axis, dtype=dtype,\n",
      "c:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide\n",
      "  ret = ret.dtype.type(ret / rcount)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A00028\n",
      "A00031\n"
     ]
    },
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[4], line 9\u001b[0m\n\u001b[0;32m      7\u001b[0m \u001b[39mfor\u001b[39;00m der \u001b[39min\u001b[39;00m \u001b[39mrange\u001b[39m (\u001b[39m12\u001b[39m):\n\u001b[0;32m      8\u001b[0m     ecg_sig \u001b[39m=\u001b[39m f[\u001b[39m'\u001b[39m\u001b[39mecg\u001b[39m\u001b[39m'\u001b[39m][der]\n\u001b[1;32m----> 9\u001b[0m     signals, _ \u001b[39m=\u001b[39m nk\u001b[39m.\u001b[39;49mecg_process(ecg_sig, sampling_rate\u001b[39m=\u001b[39;49m\u001b[39m500\u001b[39;49m)\n\u001b[0;32m     10\u001b[0m     roi_ref \u001b[39m=\u001b[39m \u001b[39mlist\u001b[39m(signals[signals[\u001b[39m'\u001b[39m\u001b[39mECG_R_Peaks\u001b[39m\u001b[39m'\u001b[39m] \u001b[39m==\u001b[39m \u001b[39m1\u001b[39m]\u001b[39m.\u001b[39mindex)\n\u001b[0;32m     12\u001b[0m     \u001b[39mfor\u001b[39;00m i \u001b[39min\u001b[39;00m \u001b[39mrange\u001b[39m(\u001b[39mlen\u001b[39m(roi_ref)):\n",
      "File \u001b[1;32mc:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\neurokit2\\ecg\\ecg_process.py:106\u001b[0m, in \u001b[0;36mecg_process\u001b[1;34m(ecg_signal, sampling_rate, method)\u001b[0m\n\u001b[0;32m    101\u001b[0m signals \u001b[39m=\u001b[39m pd\u001b[39m.\u001b[39mDataFrame(\n\u001b[0;32m    102\u001b[0m     {\u001b[39m\"\u001b[39m\u001b[39mECG_Raw\u001b[39m\u001b[39m\"\u001b[39m: ecg_signal, \u001b[39m\"\u001b[39m\u001b[39mECG_Clean\u001b[39m\u001b[39m\"\u001b[39m: ecg_cleaned, \u001b[39m\"\u001b[39m\u001b[39mECG_Rate\u001b[39m\u001b[39m\"\u001b[39m: rate, \u001b[39m\"\u001b[39m\u001b[39mECG_Quality\u001b[39m\u001b[39m\"\u001b[39m: quality}\n\u001b[0;32m    103\u001b[0m )\n\u001b[0;32m    105\u001b[0m \u001b[39m# Additional info of the ecg signal\u001b[39;00m\n\u001b[1;32m--> 106\u001b[0m delineate_signal, delineate_info \u001b[39m=\u001b[39m ecg_delineate(\n\u001b[0;32m    107\u001b[0m     ecg_cleaned\u001b[39m=\u001b[39;49mecg_cleaned, rpeaks\u001b[39m=\u001b[39;49mrpeaks, sampling_rate\u001b[39m=\u001b[39;49msampling_rate\n\u001b[0;32m    108\u001b[0m )\n\u001b[0;32m    110\u001b[0m cardiac_phase \u001b[39m=\u001b[39m ecg_phase(ecg_cleaned\u001b[39m=\u001b[39mecg_cleaned, rpeaks\u001b[39m=\u001b[39mrpeaks, delineate_info\u001b[39m=\u001b[39mdelineate_info)\n\u001b[0;32m    112\u001b[0m signals \u001b[39m=\u001b[39m pd\u001b[39m.\u001b[39mconcat([signals, instant_peaks, delineate_signal, cardiac_phase], axis\u001b[39m=\u001b[39m\u001b[39m1\u001b[39m)\n",
      "File \u001b[1;32mc:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\neurokit2\\ecg\\ecg_delineate.py:160\u001b[0m, in \u001b[0;36mecg_delineate\u001b[1;34m(ecg_cleaned, rpeaks, sampling_rate, method, show, show_type, check, **kwargs)\u001b[0m\n\u001b[0;32m    158\u001b[0m     waves \u001b[39m=\u001b[39m _ecg_delineator_cwt(ecg_cleaned, rpeaks\u001b[39m=\u001b[39mrpeaks, sampling_rate\u001b[39m=\u001b[39msampling_rate)\n\u001b[0;32m    159\u001b[0m \u001b[39melif\u001b[39;00m method \u001b[39min\u001b[39;00m [\u001b[39m\"\u001b[39m\u001b[39mdwt\u001b[39m\u001b[39m\"\u001b[39m, \u001b[39m\"\u001b[39m\u001b[39mdiscrete wavelet transform\u001b[39m\u001b[39m\"\u001b[39m]:\n\u001b[1;32m--> 160\u001b[0m     waves \u001b[39m=\u001b[39m _dwt_ecg_delineator(ecg_cleaned, rpeaks, sampling_rate\u001b[39m=\u001b[39;49msampling_rate)\n\u001b[0;32m    162\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m    163\u001b[0m     \u001b[39mraise\u001b[39;00m \u001b[39mValueError\u001b[39;00m(\n\u001b[0;32m    164\u001b[0m         \u001b[39m\"\u001b[39m\u001b[39mNeuroKit error: ecg_delineate(): \u001b[39m\u001b[39m'\u001b[39m\u001b[39mmethod\u001b[39m\u001b[39m'\u001b[39m\u001b[39m should be one of \u001b[39m\u001b[39m'\u001b[39m\u001b[39mpeak\u001b[39m\u001b[39m'\u001b[39m\u001b[39m,\u001b[39m\u001b[39m\"\u001b[39m \u001b[39m\"\u001b[39m\u001b[39m'\u001b[39m\u001b[39mcwt\u001b[39m\u001b[39m'\u001b[39m\u001b[39m or \u001b[39m\u001b[39m'\u001b[39m\u001b[39mdwt\u001b[39m\u001b[39m'\u001b[39m\u001b[39m.\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m    165\u001b[0m     )\n",
      "File \u001b[1;32mc:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\neurokit2\\ecg\\ecg_delineate.py:274\u001b[0m, in \u001b[0;36m_dwt_ecg_delineator\u001b[1;34m(ecg, rpeaks, sampling_rate, analysis_sampling_rate)\u001b[0m\n\u001b[0;32m    268\u001b[0m tpeaks, ppeaks \u001b[39m=\u001b[39m _dwt_delineate_tp_peaks(\n\u001b[0;32m    269\u001b[0m     ecg, rpeaks_resampled, dwtmatr, sampling_rate\u001b[39m=\u001b[39manalysis_sampling_rate\n\u001b[0;32m    270\u001b[0m )\n\u001b[0;32m    271\u001b[0m qrs_onsets, qrs_offsets \u001b[39m=\u001b[39m _dwt_delineate_qrs_bounds(\n\u001b[0;32m    272\u001b[0m     rpeaks_resampled, dwtmatr, ppeaks, tpeaks, sampling_rate\u001b[39m=\u001b[39manalysis_sampling_rate\n\u001b[0;32m    273\u001b[0m )\n\u001b[1;32m--> 274\u001b[0m ponsets, poffsets \u001b[39m=\u001b[39m _dwt_delineate_tp_onsets_offsets(\n\u001b[0;32m    275\u001b[0m     ppeaks, rpeaks_resampled, dwtmatr, sampling_rate\u001b[39m=\u001b[39;49manalysis_sampling_rate\n\u001b[0;32m    276\u001b[0m )\n\u001b[0;32m    277\u001b[0m tonsets, toffsets \u001b[39m=\u001b[39m _dwt_delineate_tp_onsets_offsets(\n\u001b[0;32m    278\u001b[0m     tpeaks,\n\u001b[0;32m    279\u001b[0m     rpeaks_resampled,\n\u001b[1;32m   (...)\u001b[0m\n\u001b[0;32m    283\u001b[0m     duration_onset\u001b[39m=\u001b[39m\u001b[39m0.6\u001b[39m,\n\u001b[0;32m    284\u001b[0m )\n\u001b[0;32m    286\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mdict\u001b[39m(\n\u001b[0;32m    287\u001b[0m     ECG_P_Peaks\u001b[39m=\u001b[39m_dwt_resample_points(\n\u001b[0;32m    288\u001b[0m         ppeaks, analysis_sampling_rate, desired_sampling_rate\u001b[39m=\u001b[39msampling_rate\n\u001b[1;32m   (...)\u001b[0m\n\u001b[0;32m    312\u001b[0m     ),\n\u001b[0;32m    313\u001b[0m )\n",
      "File \u001b[1;32mc:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\neurokit2\\ecg\\ecg_delineate.py:494\u001b[0m, in \u001b[0;36m_dwt_delineate_tp_onsets_offsets\u001b[1;34m(peaks, rpeaks, dwtmatr, sampling_rate, duration_onset, duration_offset, onset_weight, offset_weight, degree_onset, degree_offset)\u001b[0m\n\u001b[0;32m    488\u001b[0m duration_onset \u001b[39m=\u001b[39m _dwt_adjust_parameters(\n\u001b[0;32m    489\u001b[0m     rpeaks, sampling_rate, duration\u001b[39m=\u001b[39mduration_onset, target\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mduration\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m    490\u001b[0m )\n\u001b[0;32m    491\u001b[0m duration_offset \u001b[39m=\u001b[39m _dwt_adjust_parameters(\n\u001b[0;32m    492\u001b[0m     rpeaks, sampling_rate, duration\u001b[39m=\u001b[39mduration_offset, target\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mduration\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m    493\u001b[0m )\n\u001b[1;32m--> 494\u001b[0m degree \u001b[39m=\u001b[39m _dwt_adjust_parameters(rpeaks, sampling_rate, target\u001b[39m=\u001b[39;49m\u001b[39m\"\u001b[39;49m\u001b[39mdegree\u001b[39;49m\u001b[39m\"\u001b[39;49m)\n\u001b[0;32m    495\u001b[0m onsets \u001b[39m=\u001b[39m []\n\u001b[0;32m    496\u001b[0m offsets \u001b[39m=\u001b[39m []\n",
      "File \u001b[1;32mc:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\neurokit2\\ecg\\ecg_delineate.py:317\u001b[0m, in \u001b[0;36m_dwt_adjust_parameters\u001b[1;34m(rpeaks, sampling_rate, duration, target)\u001b[0m\n\u001b[0;32m    316\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39m_dwt_adjust_parameters\u001b[39m(rpeaks, sampling_rate, duration\u001b[39m=\u001b[39m\u001b[39mNone\u001b[39;00m, target\u001b[39m=\u001b[39m\u001b[39mNone\u001b[39;00m):\n\u001b[1;32m--> 317\u001b[0m     average_rate \u001b[39m=\u001b[39m np\u001b[39m.\u001b[39;49mmedian(signal_rate(peaks\u001b[39m=\u001b[39;49mrpeaks, sampling_rate\u001b[39m=\u001b[39;49msampling_rate))\n\u001b[0;32m    318\u001b[0m     \u001b[39mif\u001b[39;00m target \u001b[39m==\u001b[39m \u001b[39m\"\u001b[39m\u001b[39mdegree\u001b[39m\u001b[39m\"\u001b[39m:\n\u001b[0;32m    319\u001b[0m         \u001b[39m# adjust defree of dwt by sampling_rate and HR\u001b[39;00m\n\u001b[0;32m    320\u001b[0m         scale_factor \u001b[39m=\u001b[39m (sampling_rate \u001b[39m/\u001b[39m \u001b[39m250\u001b[39m) \u001b[39m/\u001b[39m (average_rate \u001b[39m/\u001b[39m \u001b[39m60\u001b[39m)\n",
      "File \u001b[1;32m<__array_function__ internals>:200\u001b[0m, in \u001b[0;36mmedian\u001b[1;34m(*args, **kwargs)\u001b[0m\n",
      "File \u001b[1;32mc:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\lib\\function_base.py:3856\u001b[0m, in \u001b[0;36mmedian\u001b[1;34m(a, axis, out, overwrite_input, keepdims)\u001b[0m\n\u001b[0;32m   3774\u001b[0m \u001b[39m@array_function_dispatch\u001b[39m(_median_dispatcher)\n\u001b[0;32m   3775\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mmedian\u001b[39m(a, axis\u001b[39m=\u001b[39m\u001b[39mNone\u001b[39;00m, out\u001b[39m=\u001b[39m\u001b[39mNone\u001b[39;00m, overwrite_input\u001b[39m=\u001b[39m\u001b[39mFalse\u001b[39;00m, keepdims\u001b[39m=\u001b[39m\u001b[39mFalse\u001b[39;00m):\n\u001b[0;32m   3776\u001b[0m \u001b[39m    \u001b[39m\u001b[39m\"\"\"\u001b[39;00m\n\u001b[0;32m   3777\u001b[0m \u001b[39m    Compute the median along the specified axis.\u001b[39;00m\n\u001b[0;32m   3778\u001b[0m \n\u001b[1;32m   (...)\u001b[0m\n\u001b[0;32m   3854\u001b[0m \n\u001b[0;32m   3855\u001b[0m \u001b[39m    \"\"\"\u001b[39;00m\n\u001b[1;32m-> 3856\u001b[0m     \u001b[39mreturn\u001b[39;00m _ureduce(a, func\u001b[39m=\u001b[39;49m_median, keepdims\u001b[39m=\u001b[39;49mkeepdims, axis\u001b[39m=\u001b[39;49maxis, out\u001b[39m=\u001b[39;49mout,\n\u001b[0;32m   3857\u001b[0m                     overwrite_input\u001b[39m=\u001b[39;49moverwrite_input)\n",
      "File \u001b[1;32mc:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\lib\\function_base.py:3752\u001b[0m, in \u001b[0;36m_ureduce\u001b[1;34m(a, func, keepdims, **kwargs)\u001b[0m\n\u001b[0;32m   3749\u001b[0m             index_out \u001b[39m=\u001b[39m (\u001b[39m0\u001b[39m, ) \u001b[39m*\u001b[39m nd\n\u001b[0;32m   3750\u001b[0m             kwargs[\u001b[39m'\u001b[39m\u001b[39mout\u001b[39m\u001b[39m'\u001b[39m] \u001b[39m=\u001b[39m out[(\u001b[39mEllipsis\u001b[39m, ) \u001b[39m+\u001b[39m index_out]\n\u001b[1;32m-> 3752\u001b[0m r \u001b[39m=\u001b[39m func(a, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n\u001b[0;32m   3754\u001b[0m \u001b[39mif\u001b[39;00m out \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[0;32m   3755\u001b[0m     \u001b[39mreturn\u001b[39;00m out\n",
      "File \u001b[1;32mc:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\lib\\function_base.py:3887\u001b[0m, in \u001b[0;36m_median\u001b[1;34m(a, axis, out, overwrite_input)\u001b[0m\n\u001b[0;32m   3885\u001b[0m         part \u001b[39m=\u001b[39m a\n\u001b[0;32m   3886\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m-> 3887\u001b[0m     part \u001b[39m=\u001b[39m partition(a, kth, axis\u001b[39m=\u001b[39;49maxis)\n\u001b[0;32m   3889\u001b[0m \u001b[39mif\u001b[39;00m part\u001b[39m.\u001b[39mshape \u001b[39m==\u001b[39m ():\n\u001b[0;32m   3890\u001b[0m     \u001b[39m# make 0-D arrays work\u001b[39;00m\n\u001b[0;32m   3891\u001b[0m     \u001b[39mreturn\u001b[39;00m part\u001b[39m.\u001b[39mitem()\n",
      "File \u001b[1;32m<__array_function__ internals>:200\u001b[0m, in \u001b[0;36mpartition\u001b[1;34m(*args, **kwargs)\u001b[0m\n",
      "File \u001b[1;32mc:\\Users\\YANIBIS\\ecg_biomarkers\\lib\\site-packages\\numpy\\core\\fromnumeric.py:784\u001b[0m, in \u001b[0;36mpartition\u001b[1;34m(a, kth, axis, kind, order)\u001b[0m\n\u001b[0;32m    782\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m    783\u001b[0m     a \u001b[39m=\u001b[39m asanyarray(a)\u001b[39m.\u001b[39mcopy(order\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mK\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[1;32m--> 784\u001b[0m a\u001b[39m.\u001b[39;49mpartition(kth, axis\u001b[39m=\u001b[39;49maxis, kind\u001b[39m=\u001b[39;49mkind, order\u001b[39m=\u001b[39;49morder)\n\u001b[0;32m    785\u001b[0m \u001b[39mreturn\u001b[39;00m a\n",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m: "
     ]
    }
   ],
   "source": [
    "Katz_list = []\n",
    "std_series = pd.Series([], dtype=float)\n",
    "Katz_derivations_std_dataframe = pd.DataFrame()\n",
    "for id in normal_ecg_age['ECG_ID'].iloc:\n",
    "    print(id)\n",
    "    with h5py.File(f'E:/1-DENIS/Biomarkers/SPH dataset/records/{id}.h5', 'r') as f:\n",
    "        for der in range (12):\n",
    "            ecg_sig = f['ecg'][der]\n",
    "            signals, _ = nk.ecg_process(ecg_sig, sampling_rate=500)\n",
    "            roi_ref = list(signals[signals['ECG_R_Peaks'] == 1].index)\n",
    "                                   \n",
    "            for i in range(len(roi_ref)):\n",
    "                temp, _ = nk.fractal_katz(ecg_sig[roi_ref[i] - 150: roi_ref[i] + 150])\n",
    "                Katz_list.append(temp)\n",
    "            \n",
    "            std_series[der] = np.std(Katz_list)\n",
    "            Katz_list = []\n",
    "            std_series.name = id           \n",
    "            \n",
    "        Katz_derivations_std_dataframe = pd.concat([Katz_derivations_std_dataframe, std_series], axis=1)        \n",
    "        std_series = pd.Series([], dtype=float)\n",
    "\n",
    "Katz_derivations_std_dataframe.index = [['I', 'II', 'III', 'aVR', 'aVL', 'aVF', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A00002</th>\n",
       "      <th>A00003</th>\n",
       "      <th>A00006</th>\n",
       "      <th>A00008</th>\n",
       "      <th>A00009</th>\n",
       "      <th>A00010</th>\n",
       "      <th>A00012</th>\n",
       "      <th>A00014</th>\n",
       "      <th>A00016</th>\n",
       "      <th>A00017</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>0.006756</td>\n",
       "      <td>0.092041</td>\n",
       "      <td>0.049438</td>\n",
       "      <td>0.039764</td>\n",
       "      <td>0.012077</td>\n",
       "      <td>0.006809</td>\n",
       "      <td>0.007000</td>\n",
       "      <td>0.032959</td>\n",
       "      <td>0.027542</td>\n",
       "      <td>0.023026</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>II</th>\n",
       "      <td>0.004120</td>\n",
       "      <td>0.018387</td>\n",
       "      <td>0.034180</td>\n",
       "      <td>0.009041</td>\n",
       "      <td>0.011482</td>\n",
       "      <td>0.003906</td>\n",
       "      <td>0.011902</td>\n",
       "      <td>0.009621</td>\n",
       "      <td>0.007500</td>\n",
       "      <td>0.109863</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>III</th>\n",
       "      <td>0.013184</td>\n",
       "      <td>0.023636</td>\n",
       "      <td>0.069885</td>\n",
       "      <td>0.013695</td>\n",
       "      <td>0.110046</td>\n",
       "      <td>0.004871</td>\n",
       "      <td>0.027496</td>\n",
       "      <td>0.015083</td>\n",
       "      <td>0.008011</td>\n",
       "      <td>0.048645</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVR</th>\n",
       "      <td>0.003759</td>\n",
       "      <td>0.045776</td>\n",
       "      <td>0.026810</td>\n",
       "      <td>0.007103</td>\n",
       "      <td>0.010544</td>\n",
       "      <td>0.003357</td>\n",
       "      <td>0.007366</td>\n",
       "      <td>0.006924</td>\n",
       "      <td>0.014946</td>\n",
       "      <td>0.017639</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVL</th>\n",
       "      <td>0.030334</td>\n",
       "      <td>0.085876</td>\n",
       "      <td>0.071289</td>\n",
       "      <td>0.028885</td>\n",
       "      <td>0.013382</td>\n",
       "      <td>0.008049</td>\n",
       "      <td>0.011223</td>\n",
       "      <td>0.087280</td>\n",
       "      <td>0.018097</td>\n",
       "      <td>0.033844</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVF</th>\n",
       "      <td>0.006355</td>\n",
       "      <td>0.016495</td>\n",
       "      <td>0.037445</td>\n",
       "      <td>0.009995</td>\n",
       "      <td>0.024582</td>\n",
       "      <td>0.004086</td>\n",
       "      <td>0.081604</td>\n",
       "      <td>0.008728</td>\n",
       "      <td>0.006664</td>\n",
       "      <td>0.081238</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V1</th>\n",
       "      <td>0.005783</td>\n",
       "      <td>0.073486</td>\n",
       "      <td>0.021454</td>\n",
       "      <td>0.013000</td>\n",
       "      <td>0.010628</td>\n",
       "      <td>0.003899</td>\n",
       "      <td>0.032654</td>\n",
       "      <td>0.007755</td>\n",
       "      <td>0.023758</td>\n",
       "      <td>0.044525</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V2</th>\n",
       "      <td>0.003654</td>\n",
       "      <td>0.012207</td>\n",
       "      <td>0.012939</td>\n",
       "      <td>0.009842</td>\n",
       "      <td>0.021362</td>\n",
       "      <td>0.026505</td>\n",
       "      <td>0.018784</td>\n",
       "      <td>0.009293</td>\n",
       "      <td>0.005981</td>\n",
       "      <td>0.016434</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V3</th>\n",
       "      <td>0.023834</td>\n",
       "      <td>0.009888</td>\n",
       "      <td>0.013748</td>\n",
       "      <td>0.014275</td>\n",
       "      <td>0.024719</td>\n",
       "      <td>0.013947</td>\n",
       "      <td>0.015198</td>\n",
       "      <td>0.027359</td>\n",
       "      <td>0.009583</td>\n",
       "      <td>0.013893</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V4</th>\n",
       "      <td>0.006866</td>\n",
       "      <td>0.012497</td>\n",
       "      <td>0.005577</td>\n",
       "      <td>0.011703</td>\n",
       "      <td>0.015083</td>\n",
       "      <td>0.010498</td>\n",
       "      <td>0.012093</td>\n",
       "      <td>0.007069</td>\n",
       "      <td>0.038300</td>\n",
       "      <td>0.009903</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V5</th>\n",
       "      <td>0.009087</td>\n",
       "      <td>0.016464</td>\n",
       "      <td>0.006752</td>\n",
       "      <td>0.020538</td>\n",
       "      <td>0.011909</td>\n",
       "      <td>0.004593</td>\n",
       "      <td>0.007748</td>\n",
       "      <td>0.009201</td>\n",
       "      <td>0.022385</td>\n",
       "      <td>0.019287</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V6</th>\n",
       "      <td>0.010551</td>\n",
       "      <td>0.037964</td>\n",
       "      <td>0.010315</td>\n",
       "      <td>0.006073</td>\n",
       "      <td>0.010567</td>\n",
       "      <td>0.020798</td>\n",
       "      <td>0.013985</td>\n",
       "      <td>0.006905</td>\n",
       "      <td>0.015930</td>\n",
       "      <td>0.013565</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       A00002    A00003    A00006    A00008    A00009    A00010    A00012  \\\n",
       "I    0.006756  0.092041  0.049438  0.039764  0.012077  0.006809  0.007000   \n",
       "II   0.004120  0.018387  0.034180  0.009041  0.011482  0.003906  0.011902   \n",
       "III  0.013184  0.023636  0.069885  0.013695  0.110046  0.004871  0.027496   \n",
       "aVR  0.003759  0.045776  0.026810  0.007103  0.010544  0.003357  0.007366   \n",
       "aVL  0.030334  0.085876  0.071289  0.028885  0.013382  0.008049  0.011223   \n",
       "aVF  0.006355  0.016495  0.037445  0.009995  0.024582  0.004086  0.081604   \n",
       "V1   0.005783  0.073486  0.021454  0.013000  0.010628  0.003899  0.032654   \n",
       "V2   0.003654  0.012207  0.012939  0.009842  0.021362  0.026505  0.018784   \n",
       "V3   0.023834  0.009888  0.013748  0.014275  0.024719  0.013947  0.015198   \n",
       "V4   0.006866  0.012497  0.005577  0.011703  0.015083  0.010498  0.012093   \n",
       "V5   0.009087  0.016464  0.006752  0.020538  0.011909  0.004593  0.007748   \n",
       "V6   0.010551  0.037964  0.010315  0.006073  0.010567  0.020798  0.013985   \n",
       "\n",
       "       A00014    A00016    A00017  \n",
       "I    0.032959  0.027542  0.023026  \n",
       "II   0.009621  0.007500  0.109863  \n",
       "III  0.015083  0.008011  0.048645  \n",
       "aVR  0.006924  0.014946  0.017639  \n",
       "aVL  0.087280  0.018097  0.033844  \n",
       "aVF  0.008728  0.006664  0.081238  \n",
       "V1   0.007755  0.023758  0.044525  \n",
       "V2   0.009293  0.005981  0.016434  \n",
       "V3   0.027359  0.009583  0.013893  \n",
       "V4   0.007069  0.038300  0.009903  \n",
       "V5   0.009201  0.022385  0.019287  \n",
       "V6   0.006905  0.015930  0.013565  "
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Katz_derivations_std_dataframe"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "V5     0.012794\n",
       "V4     0.012955\n",
       "V2     0.013695\n",
       "aVR    0.014427\n",
       "V6     0.014664\n",
       "V3     0.016647\n",
       "II     0.022003\n",
       "V1     0.023712\n",
       "aVF    0.027740\n",
       "I      0.029739\n",
       "III    0.033478\n",
       "aVL    0.038849\n",
       "dtype: float16"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Katz_derivations_std_dataframe.mean(axis=1).sort_values(ascending=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [],
   "source": [
    "with h5py.File('E:/1-DENIS/Biomarkers/SPH dataset/records/A00002.h5', 'r') as f:\n",
    "    ecg_sig = f['ecg'][10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x277a08cdeb0>]"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAiMAAAGdCAYAAADAAnMpAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAPYQAAD2EBqD+naQAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nO3deXiU5b3/8c8kM5lJQhIIgSwQIMi+QxDBKqhYLK6ttrVq1VZtS60rtZ669LTH/k7xtNZST11qXahHq9ZC1dalYkVwR3aQXbYACQFC9sz+/P6YzCSREDLJM5lJnvfrunJdZvJM5o4PST657+/9vW2GYRgCAACIk6R4DwAAAFgbYQQAAMQVYQQAAMQVYQQAAMQVYQQAAMQVYQQAAMQVYQQAAMQVYQQAAMSVPd4DaI9gMKiDBw8qIyNDNpst3sMBAADtYBiGampqVFBQoKSkE89/dIswcvDgQRUWFsZ7GAAAoANKSko0cODAE368W4SRjIwMSaEvJjMzM86jAQAA7VFdXa3CwsLI7/ET6RZhJLw0k5mZSRgBAKCbOVmJBQWsAAAgrggjAAAgrggjAAAgrggjAAAgrggjAAAgrggjAAAgrggjAAAgrggjAAAgrggjAAAgrggjAAAgrggjAAAgrggjAAAgrggjQBdZtq1cr6w7EO9hAEDC6Ran9gLdnT8Q1A1/XqVA0FCDN6BvTRsU7yEBQMJgZgToAodrPQoEDUnSff/crAZvIM4jAoDEQRgBukBZlTvy3/XegMqq3W1cDQDWQhgBukDzMCJJlfXeOI0EABIPYQToAl+cCams98VpJACQeAgjQBc4Low0MDMCAGGEEaALHL9M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wtddeq+XLl0c+zr3oOiUlJbr11lv11ltvyeVynfA67om5LLlMk5OTo+Tk5OMSanl5+XFpF7GVl5cnSW3ei7y8PHm9Xh07duyE1yB6N998s1599VUtW7ZMAwcOjDzOPel6KSkpGjZsmKZOnaoFCxZo4sSJ+v3vf8+9iIPVq1ervLxcxcXFstvtstvtWr58uR566CHZ7fbI/1PuibksGUZSUlJUXFyspUuXtnh86dKlOv300+M0KmsqKipSXl5ei3vh9Xq1fPnyyL0oLi6Ww+FocU1paak2bdrE/eoAwzB00003acmSJXrnnXdUVFTU4uPck/gzDEMej4d7EQezZ8/Wxo0btW7dba1gvwAAAaJJREFUusjb1KlTddVVV2ndunUaOnQo9yQW4lM3G3/hrb1PPvmksXnzZuO2224z0tPTjT179sR7aD1OTU2NsXbtWmPt2rWGJOPBBx801q5dG9lGff/99xtZWVnGkiVLjI0bNxpXXHFFq9vkBg4caLz99tvGmjVrjHPOOYdtch30wx/+0MjKyjLeffddo7S0NPJWX18fuYZ70nXuuusuY8WKFcbu3buNDRs2GHfffbeRlJRkvPXWW4ZhcC8SQfPdNIbBPYkFy4YRwzCMhx9+2Bg8eLCRkpJiTJkyJbK1EeZatmyZIem4t2uvvdYwjNBWuZ///OdGXl6e4XQ6jZkzZxobN25s8TkaGhqMm266ycjOzjZSU1ONCy+80Ni3b18cvprur7V7Icl4+umnI9dwT7rOddddF/k51K9fP2P27NmRIGIY3ItE8MUwwj0xn80wDCM+czIAAAAWrRkBAACJgzACAADiijACAADiijACAADiijACAADiijACAADiijACAADiijACAADiijACAADiijACAADiijACAADiijACAADi6v8D/8X0o3Yi+zUAAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(ecg_sig[50:500])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "ecg_biomarkers",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
